from flask import Flask, g, abort

app = Flask(__name__)
@app.before_request
def create_user():
    g.user_id = 123

def feng(func):
    def wrapper(*args,**kwargs):
        if g.user_id is None:
            abort(401)
        else:

            return func(*args,**kwargs)
    return wrapper

@app.route('/')
@feng
def liang():
    user_id = g.user_id
    username = '冯亮'
    print('小姐姐')
    return '输出的结果{}{}'.format(user_id,username)

if __name__ == '__main__':
    app.run(host="0.0.0.0", port=5000, debug=True)
